import requests
import json


# 香港卫视
class XiangGang():
    url = ''

    def __init__(self):
        self.url = "http://lives.hkstv.tv:5080/api/player/mutfysrq?mode=live&protocal=hls"
        self.headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
        }
        self.session = requests.session()

    def __get_data(self):
        result = self.session.get(self.url)
        xiangGangObject = json.loads(result.text)
        if xiangGangObject:
            return xiangGangObject['url']

    def get_live_sources(self):
        return {
            "name": "香港卫视",
            "url": self.__get_data()
        }
